#include "MainUI.h"
#include <QApplication>
#include <QThread>
#include <QPixmap>
#include <QSplashScreen>
#include <windows.h>
#include <QMovie>
#include <QLabel>
#include <QDateTime>

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    
#if 0 /* 开启/关闭启动加载画面*/
    
#if 1 /* 1使用静态加载动画，0使用动态加载动画*/
    QPixmap pix(":/image/start_static.png");
    QSplashScreen splash(pix);
    splash.setWindowFlags(splash.windowFlags() | Qt::WindowStaysOnTopHint);
    splash.show();
    
    /* 设置加载画面时间 & 记录开始时间*/
    const int loadingTimeMS = 1200;
    const QDateTime lastTime = QDateTime::currentDateTime();
    do
    {
        a.processEvents();
    }while(lastTime.msecsTo(QDateTime::currentDateTime()) <= loadingTimeMS);
    
    
#else
    QPixmap pix(":/image/startup.gif");
    QSplashScreen splash(pix);
    QLabel splashlabel(&splash);
    QMovie splashgif(":/image/start_run_01.gif");
    splashlabel.setMovie(&splashgif);
    splashgif.start();
    splash.show();
    splash.setCursor(Qt::BlankCursor);//不显示鼠标外观
    for(int i=0;i<15000;i+=splashgif.speed()){
        QCoreApplication::processEvents();
        Sleep(splashgif.speed());
    }
#endif
    
    MainUI w;
    w.show();
    
    splash.finish(&w);//程序启动画面结束

#else
    
    MainUI w;
    w.show();
    
#endif
    
    return a.exec();
}
